//
//  ZYHomeMemanagerController.m
//  优学荟管理系统
//
//  Created by edz on 2017/12/25.
//  Copyright © 2017年 星道三好. All rights reserved.
//
#import "SAWCorrectHomeWorkVC.h"
#import "ZYHomeMemanagerController.h"
#import "ZYHomeCouseListController.h"
#import "ZYHomeAssignmentController.h"
#import "ZYHomeMemangersCell.h"
#import "HMWorkSelectCourseVC.h"
#define kCell @"cell"
@interface ZYHomeMemanagerController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,strong) NSMutableArray *dataSource;
@property (nonatomic,strong) NSMutableArray *dataIconArray;
@property (nonatomic,strong) NSMutableArray *dataSourceTwo;
@property (nonatomic,strong) NSMutableArray *dataIconArrayTwo;
@property (nonatomic,strong) NSMutableArray *dataSourceThree;
@property (nonatomic,strong) NSMutableArray *dataIconArrayThree;
@property (nonatomic,strong) UIView *allView;
@end

@implementation ZYHomeMemanagerController

- (NSMutableArray *)dataSourceThree{
    
    if (_dataSourceThree == nil) {
        _dataSourceThree = [NSMutableArray arrayWithObjects:@"错题集中营", nil];
    }
    return _dataSourceThree;
}
- (NSMutableArray *)dataSourceTwo{
    
    if (_dataSourceTwo == nil) {
        self.dataSourceTwo = [NSMutableArray arrayWithObjects:@"作业批阅", nil];
    }
    return _dataSourceTwo;
}

- (NSMutableArray *)dataIconArray{
    
    if (_dataIconArray == nil) {
        self.dataIconArray = [[NSMutableArray alloc]initWithObjects:@"icon_arrange_homework_default", nil];
    }
    
    return _dataIconArray;
}
- (NSMutableArray *)dataIconArrayTwo{
    
    if (_dataIconArrayTwo == nil) {
        self.dataIconArrayTwo = [NSMutableArray arrayWithObjects:@"icon_read_over_default", nil];
        
    }
    
    
    return _dataIconArrayTwo;
}


- (NSMutableArray *)dataIconArrayThree{
    
    if (_dataIconArrayThree == nil) {
        _dataIconArrayThree = [[NSMutableArray alloc]initWithObjects:@"icon_arrange_homework_default", nil];
    }
    
    return _dataIconArrayThree;
}

- (NSMutableArray *)dataSource{
    
    if (_dataSource == nil) {
        self.dataSource = [[NSMutableArray alloc]initWithObjects:@"布置作业",nil];
    }
    
    return _dataSource;
}



- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = RGBColor(245, 245, 245);
    self.title = @"作业管理";
    

    
    
    [self setUpSuperView];
}







- (void)setUpSuperView{
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(8, 0, kScreenWidth - 16, kScreenHeight - 64)];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    [self.view addSubview:self.tableView];
    self.tableView.backgroundColor = RGBColor(245, 245, 245);
    self.tableView.tableFooterView = [UIView new];
    [self.tableView registerClass:[ZYHomeMemangersCell class] forCellReuseIdentifier:kCell];
    self.allView  = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 15)];
    self.allView.backgroundColor = ColorRGB(245, 245, 245);
    self.tableView.tableHeaderView = self.allView;


    
}


#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 3;
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    if (0 == section) {
        
          return self.dataSource.count;
    }else if (1 == section) {
        
        return self.dataSourceTwo.count;
    }else{
          return self.dataSourceThree.count;
    }
    
  
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
      ZYHomeMemangersCell *cell = [tableView dequeueReusableCellWithIdentifier:kCell forIndexPath:indexPath];
    if (0 == indexPath.section) {
        
        cell.nameLabel.text = self.dataSource[indexPath.row];
        [cell.photoIamgeButotn setImage:[UIImage imageNamed:self.dataIconArray[indexPath.row]] forState:(UIControlStateNormal)];
    }else if (1 == indexPath.section) {
        
        cell.nameLabel.text = self.dataSourceTwo[indexPath.row];
        [cell.photoIamgeButotn setImage:[UIImage imageNamed:self.dataIconArrayTwo[indexPath.row]] forState:(UIControlStateNormal)];
    }else{
        
         cell.nameLabel.text = self.dataSourceThree[indexPath.row];
        [cell.photoIamgeButotn setImage:[UIImage imageNamed:self.dataIconArrayThree[indexPath.row]] forState:(UIControlStateNormal)];
    }
    
    
    
  
  
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    if (0 == indexPath.section) {
        HMWorkSelectCourseVC *vc = [HMWorkSelectCourseVC new];
        if (self.isTeacher) {
            vc.isTeacher = YES;
        }
        [self.navigationController pushViewController:vc animated:YES];
   
    }else if (1 == indexPath.section) {
       [self.navigationController pushViewController:[ZYHomeCouseListController new] animated:YES];
        
    }else{
        
      
        [self.navigationController pushViewController:[SAWCorrectHomeWorkVC new] animated:YES];
        
    }
    
    
    
    
}


- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    
    return 15;
}


- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    
    
    UIView *vv = [UIView new];
    
    vv.backgroundColor = ColorRGB(245, 245, 245);
    
    return vv;
}












@end
